{extend name="index_layout"/}
{block name="main"}
<div class="layui-card">
    <div class="layui-card-header">表单列表</div>
    <div class="layui-card-body">
        <table class="layui-hide" id="currentTable" lay-filter="currentTable" data-auth-delete="{:$auth->check('auth.formLog/delete')}"></table>
    </div>
</div>

<script type="text/html" id="phone">
    <span data-clipboard-text="{{ d.phone }}" class="copy">{{ d.phone }}</span>
</script>
<script type="text/html" id="ip">
    <span data-clipboard-text="{{ d.ip }}" class="copy">{{ d.ip }}</span>
</script>

{/block}
{block name="script"}
<script>
layui.use(['yznTable', 'clipboard'], function() {
    var table = layui.yznTable,
        clipboard = layui.clipboard;

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTable',
        delete_url: "{:url('admin/FormLog/del')}",
    };

    table.render({
        init: init,
        toolbar: ['refresh', 'delete'],
        url: '{:url("admin/FormLog/index")}',
        cols: [
            [
                {type: 'checkbox'},
                { field: 'id', width: 80, title: 'ID', sort: true },
                { field: 'product',  title: '咨询项目' },
                { field: 'realname', width: 100, title: '姓名' },
                { field: 'phone', width: 140, title: '手机号',templet: '#phone' },
                { field: 'ip', width: 140, title: '客户端IP',templet: '#ip' },
                { field: 'create_time', width: 180, title: '提交时间', search: 'range' },
            ]
        ],
        page: {}
    });

    yznTable.bindevent();
    var clipboardObj = new clipboard('.copy');
    clipboardObj.on('success', function (e) {
        layer.msg("复制成功", {icon: 1});
    });
    clipboardObj.on('error', function (e) {
        layer.msg("复制失败！请手动复制", {icon: 2});
    });
});
</script>
{/block}